package lovo.practice_7_13;

import lovo.Util.Util;
import javax.swing.*;
import java.awt.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

/**
 * 斗地主类
 */
public class DouDIZhu extends JFrame {
    public ArrayList<Card> getList() {
        return list;
    }

    public List getPlay1() {
        return play1;
    }

    public List getPlay2() {
        return play2;
    }

    public List getPlay3() {
        return play3;
    }

    public List getBase() {
        return base;
    }

    private ArrayList<Card> list = new ArrayList();
    private List play1 = new ArrayList();
    private List play2 = new ArrayList();
    private List play3 = new ArrayList();
    private List base = new ArrayList();

    String[] pointArr = {"3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15"};
    String[] typeArr = {"1", "2", "3", "4"};

    public DouDIZhu() {

    }


    //初始化扑克
    public void init() {
        for (int i = 0; i < pointArr.length; i++) {
            for (int j = 0; j < typeArr.length; j++) {
                list.add(new Card(pointArr[i], typeArr[j], i, j));
            }
        }
        list.add(new Card("16", "1", 16, 0));
        list.add(new Card("17", "1", 17, 0));
    }

    //洗牌
    public void XiPai() {
        Collections.shuffle(list);
    }

    //发牌
    public void Fapai() {
        play1 = list.subList(0, 17);
        play2 = list.subList(17, 34);
        play3 = list.subList(34, 51);
        base = list.subList(51, 54);

    }
    //理牌
    public void LiPai(List list) {
        list.sort(new Comparator<Card>() {
            @Override
            public int compare(Card o1, Card o2) {
                if (o1.getPointvalue() == o2.getPointvalue()) {
                    return o1.getTypevalue() - o2.getTypevalue();
                } else {
                    return o1.getPointvalue() - o2.getPointvalue();
                }
            }
        });

    }



}




